
/**
 * 系统公共对象
 */
drgUI={
		// 成功提示
	    success:function(info,time){
	    	var outTime=3000;
	    	if(time){
	    		outTime=time;
	    	}
	    	layer.msg(info, {
            icon: 1,
            time: outTime
           });
	    },
	    //错误提示
	    error:function(info,time){
	    	var outTime=3000;
	    	if(time){
	    		outTime=time;
	    	}
	    	layer.msg(info, {
            icon: 2,
            time: outTime
           });
	    },
	    //警告提示
	    warning:function(info,time){
	    	var outTime=3000;
	    	if(time){
	    		outTime=time;
	    	}
	    	layer.msg(info, {
            icon: 7,
            time: outTime
           });
	    },
	    alert:function(info,functionn){
	    	var laert= layer.alert(info, {
			    skin: 'layui-layer-green'
			    ,closeBtn: 0
			    ,anim: 4 //动画类型
			  },function(){
			  	if(functionn!=undefined){
			  		layer.close(laert);
			  		 functionn();
			  	}else{
			  		layer.close(laert);
			  	}
			  });
	    },
	    //tips
	    tips : function() {
	    	$('.drgtips').unbind();
			$('.drgtips').mouseenter(function() {
				 var newClass=getRandomString(8);
				 $(this).addClass(newClass);
				  drgTips=layer.tips($(this).attr('tips'),
				  '.'+newClass, {
				  tips: [1, 'rgb(23, 24, 25)'],
				  time: 900000
				  });
				 });
			$('.drgtips').mouseleave(function() {
					layer.close(drgTips);
					var className = $(this).attr("class");
					var newClass = className.substr(-8);
					$(this).removeClass(newClass);
				});
	   },
	    //锁定提示
	    lock:function(info,time){
	    	var outTime=3000;
	    	if(time){
	    		outTime=time;
	    	}
	    	layer.msg(info, {
            icon: 4,
            skin: 'layui-layer-lan',
            time: outTime
           });
	    },
	    load:function(type){
		  var load=layer.load(type, {
				shade: [0.8,'#59b8dc59'],
				skin: 'layui-layer-rim', //加上边框
				zIndex:466 //层优先级
				});	
		 return load;
	    },
	    loadClose:function(index){
	    	layer.close(index);
	    },
	    //消息确认框
	    confirm: function (options) {
	    	var callSure=options.callSure;
	    	var callCancel=options.callCancel;
	    	var btnl=options.btnl==undefined?'确定':options.btnl;
	    	var btnr=options.btnr==undefined?'取消':options.btnr;
			layer.confirm(options.content, {
			    btn: [btnl, btnr],
			    skin: 'layui-layer-green'
			 }, function (index) {
			   if(callSure!=undefined){
					callSure();
				}
			    layer.close(index);
			}, function (index) {
				if(callCancel!=undefined){
					callCancel();
				}
			    layer.close(index);
			});
       },
       open: function (title,url,width,height){
       	if(width==undefined)width=700;
       	if(height==undefined)height=450;
       	layer.open({
			  type: 2,
			  area: [width+'px', height+'px'],
			  fixed: true, //固定
			  maxmin: false,//扩大或缩小
			  skin: 'layui-layer-green',
			  title:title,
			  content: url
			});
       },
	 setAjaxData : function(tabId) {
		if (paramTabPage[tabId].depCode != undefined
				&& paramTabPage[tabId].depCode != "") {
			paramTabPage[tabId]['pardepCode'] = paramTabPage[tabId].depCode;
		}else{
			paramTabPage[tabId].depCode="";
		}
		if (paramTabPage[tabId].depGroupCode != undefined
				&& paramTabPage[tabId].depGroupCode != "") {
			paramTabPage[tabId]['pardepgroupCode'] = paramTabPage[tabId].depGroupCode;
		}else{
			paramTabPage[tabId].depGroupCode="";
		}
		if (paramTabPage[tabId].wardCode != undefined
				&& paramTabPage[tabId].wardCode != "") {
			paramTabPage[tabId]['parwardCode'] = paramTabPage[tabId].wardCode;
		}else{
			paramTabPage[tabId].wardCode="";
		}
		if (paramTabPage[tabId].mdcCode != undefined
				&& paramTabPage[tabId].mdcCode != "") {
			paramTabPage[tabId]['parmdcCode'] = paramTabPage[tabId].mdcCode;
		}else{
			paramTabPage[tabId].mdcCode="";
		}
		if (paramTabPage[tabId].adrgCode != undefined
				&& paramTabPage[tabId].adrgCode != "") {
			paramTabPage[tabId]['paradrgCode'] = paramTabPage[tabId].adrgCode;
		}else{
			paramTabPage[tabId].adrgCode="";
		}
		if (paramTabPage[tabId].drgCode != undefined
				&& paramTabPage[tabId].drgCode != "") {
			paramTabPage[tabId]['pardrgCode'] = paramTabPage[tabId].drgCode;
		}else{
			paramTabPage[tabId].drgCode="";
		}
		if (paramTabPage[tabId].groupName != undefined
				&& paramTabPage[tabId].groupName != "") {
			paramTabPage[tabId]['pargroupName'] = paramTabPage[tabId].groupName;
		}else{
			paramTabPage[tabId].groupName="";
		}
		var param = $.extend(true, {}, paramTabPage[tabId]);
		for (var key in param) {
			if (param[key] == undefined || param[key] ==null || param[key] =='null') {
				param[key] ='';
			}
		}
		return param;
	},
	bindAjaxStart:function(type){
		if(type=='1'){
			 $(document).ajaxStart(function(){
			     layerload=drgUI.load(2);
			  });
		}else if( type=='0'){
			$(document).unbind('ajaxStart');//暂时去掉模态框
		}
	},
	drgLogOut:function(){
		//系统退出操作
		$.post(contextPath + "/logout.dhc", function(data) {
			if(data.success){
				var exp = new Date();
				exp.setTime(exp.getTime() - 1);
				var cval=getCookie(name);
				if(cval!=null)
				document.cookie= name + "="+cval+";expires="+exp.toGMTString();
				// DRG退出地址。
				var drgLogoutUrl = data.data ;
				// DRG退出
				window.location.href = drgLogoutUrl ; 
			}
		}); 
	},
	isNumber:function(num){
		if(num==""){
			return false;
		}
		num = num + '';
		num = num.replace(',', '');
		num = num.replace('，', '');
		num = num.replace(' ', '');
		if(isNaN(num)){
			return false;
		}else{
			return true;
		}
		
	}
};
 
/**
 * 百分数排序
 */
 jQuery.fn.dataTableExt.oSort['number-fate-asc']  = function(s1,s2) {  
	// 调整正负数排序
	var d1 = "";
	var d2 = "";
	var d1 = $(s1).text().substring(1, 2)
			+ $(s1).text().substring(3, $(s1).text().length);
	var d2 = $(s2).text().substring(1, 2)
			+ $(s2).text().substring(3, $(s2).text().length);

	if (d1 == "" || d1 == "-") {
		d1 = "0";
	}
	if (d2 == "" || d2 == "-") {
		d2 = "0";
	}
	d1 = d1.replace('%', '');
	d2 = d2.replace('%', '');

	return ((parseFloat(d1) < parseFloat(d2))
			? -1
			: (parseFloat(d1) > parseFloat(d2)) ? 1 : 0)
 };  
   
 jQuery.fn.dataTableExt.oSort['number-fate-desc'] = function(s1,s2) {  
//调整正负数排序
var d1 = "";
var d2 = "";
var d1 = $(s1).text().substring(1,2)+$(s1).text().substring(3,$(s1).text().length);
var d2 = $(s2).text().substring(1,2)+$(s2).text().substring(3,$(s2).text().length);
if(d1=="" || d1=="-"){
 d1 = "0";
}
if(d2=="" || d2=="-"){
d2="0";
}
 d1 = d1.replace('%','');  
 d2 = d2.replace('%',''); 
     return ((parseFloat(d1) < parseFloat(d2)) ? 1 : (parseFloat(d1) > parseFloat(d2)) ? -1 : 0);
 };  
 
 /**
  * 带html标签的数字排序
  */
  jQuery.fn.dataTableExt.oSort['number-html-asc']  = function(s1,s2) {  

	var d1 = $(s1).text().replace(",", "");
	var d2 = $(s2).text().replace(",", "");
	if (d1 == "") {
		d1 = "0";
	}
	if (d2 == "") {
		d2 = "0";
	}
	if (isNaN(parseFloat(d1))) {
		d1 = 0;
	} else {
		d1 = parseFloat(d1);
	}
	if (isNaN(parseFloat(d2))) {
		d2 = 0;
	} else {
		d2 = parseFloat(d2);
	}

	return ((d1 < d2) ? -1 : (d1 > d2) ? 1 : 0)
  };  
    
jQuery.fn.dataTableExt.oSort['number-html-desc'] = function(s1,s2) {  
 var d1 = $(s1).text().replace(",", "");
	var d2 = $(s2).text().replace(",", "");
	if (d1 == "" || d1 == "-") {
		d1 = "0";
	}
	if (d2 == "" || d2 == "-") {
		d2 = "0";
	}
	if (isNaN(parseFloat(d1))) {
		d1 = 0;
	} else {
		d1 = parseFloat(d1);
	}
	if (isNaN(parseFloat(d2))) {
		d2 = 0;
	} else {
		d2 = parseFloat(d2);
	}
	return ((d1 < d2) ? 1 : (d1 > d2) ? -1 : 0);
  };  
  
  /**
   * 单元格中数字后有html标签的排序
   */
  jQuery.fn.dataTableExt.oSort['number-beforeHtml-asc']  = function(s1,s2) {  
		var d1 = $(s1).text();
		var d2 = $(s2).text();
		if(d1=="" || d1=="-"){
		 d1 = "0";
		  }
		if(d2=="" || d2=="-"){
		d2="0";
		}
		d1 = s1.replace(/([\d\.]*?)<.*/,'$1');
		d2 = s2.replace(/([\d\.]*?)<.*/,'$1');
        return ((parseFloat(d1) < parseFloat(d2)) ? -1 : (parseFloat(d1) > parseFloat(d2)) ? 1 : 0)
   };  
     
   jQuery.fn.dataTableExt.oSort['number-beforeHtml-desc'] = function(s1,s2) {  
		var d1 = $(s1).text();
		var d2 = $(s2).text();
		if(d1==""){
		 d1 = "0";
		  }
		if(d2==""){
		d2="0";
		}
		d1 = s1.replace(/([\d\.]*?)<.*/g,'$1');
		d2 = s2.replace(/([\d\.]*?)<.*/g,'$1');
       return ((parseFloat(d1) < parseFloat(d2)) ? 1 : (parseFloat(d1) > parseFloat(d2)) ? -1 : 0);
   };  
 
 
 //数字排序
   jQuery.fn.dataTableExt.oSort['numeric-comma-asc']  = function(a,b) { 
		var a1 = a.replace(",","");
		if(a1 && a1.indexOf("万元")>=0){
			a1 = a1.substring(0,a1.lastIndexOf("万元"));
			a1 = Number(a1)*10000;
		}
		
		var b1 = b.replace(",","");
		if(b1 && b1.indexOf("万元")>=0){
			b1 = b1.substring(0,b1.lastIndexOf("万元"));
		   		b1 = Number(b1)*10000;
		   	}
       return ((parseFloat(a1) < parseFloat(b1)) ? -1 : (parseFloat(a1) > parseFloat(b1)) ? 1 : 0)
   };

   jQuery.fn.dataTableExt.oSort['numeric-comma-desc']  = function(a,b) {
		var a1 = a.replace(",","");
		if(a1 && a1.indexOf("万元")>=0){
			a1 = a1.substring(0,a1.lastIndexOf("万元"));
			a1 = Number(a1)*10000;
		}
		var b1 = b.replace(",","");
		if(b1 && b1.indexOf("万元")>=0){
			b1 = b1.substring(0,b1.lastIndexOf("万元"));
		   		b1 = Number(b1)*10000;
		   	}   	
       return ((parseFloat(a1) < parseFloat(b1)) ? 1 : (parseFloat(a1) > parseFloat(b1)) ? -1 : 0)
   };
   //中文排序
   jQuery.fn.dataTableExt.oSort['chinese-string-asc'] = function(s1,s2){
		if(s1=="" || s1=="-"){
		 s1 = "0";
		  }
		if(s2=="" || s2=="-"){
		s2="0";
	  	 }
	   return s1.localeCompare(s2);
   }
   jQuery.fn.dataTableExt.oSort['chinese-string-desc']  = function(s1,s2) {
		if(s1=="" || s1=="-"){
		 s1 = "0";
		  }
		if(s2=="" || s2=="-"){
		s2="0";
	  	}
	   return s2.localeCompare(s1);
	   
   }
   
 // 数字排序
   jQuery.fn.dataTableExt.oSort['numeric-input-asc']  = function(a,b) { 
	   	var $a = $(a);
	   	var $b = $(b);
	   	var a1 = $a.val();
	   	var b1 = $b.val();
       return ((parseFloat(a1) < parseFloat(b1)) ? -1 : (parseFloat(a1) > parseFloat(b1)) ? 1 : 0)
   };

   jQuery.fn.dataTableExt.oSort['numeric-input-desc']  = function(a,b) {
	   	var $a = $(a);
	   	var $b = $(b);
	   	var a1 = $a.val();
	   	var b1 = $b.val();
       return ((parseFloat(a1) < parseFloat(b1)) ? 1 : (parseFloat(a1) > parseFloat(b1)) ? -1 : 0)
   };
 
  /**
   * @ Discription:数据格式化函数
   * @Autor ：liuhongjun
   * @Date  ：2018年4月1日上午10:14:49
   */
 function formatNumber(num,scale) {
	 if(num==undefined || num==null){
		 return '-';
	 }
	num=num+"";
	var parameters = { 
			currency: 'CNY'
	 };
	if(num && (num.indexOf(',')>0||num.indexOf('，')>0)){
		num=num.replace('，','');
		num=num.replace(',','');
	}
	if(isNaN(num)){
		 return num;
	 }
	if(num && num.indexOf('.')>0){
		if(!isNaN(scale)){
			var dic=num.split('.')[1];
			if(dic && dic.length>scale){
				var pattern='#,##0.'
				for(var i=0;i<scale;i++){
					pattern+='0';
				}
				pattern+=' !';
				parameters['pattern']=pattern;
			}else if (dic && dic.length<=scale){
				parameters['pattern']='#,##0.00 !';
			}else if(dic){
				parameters['pattern']='#,##0 !';
			}
		}else{
			parameters['pattern']='#,##0.00 !';
		}
	}else{
		parameters['pattern']='#,##0 !';
	}
	num=OSREC.CurrencyFormatter.format(num,parameters);
	if(num){
		num=num.substring(0,num.length-1);
	}
	return num ;
}
/**
 * 
 * @ Discription:比率类指标比较
 * @Autor ：liuhongjun
 * @param ty
 * @param ly
 * @returns
 * any
 * drgsCommon.js
 * 2017年6月12日下午6:41:23
 */
function comparePercent(ty,ly) {
	if (isNaN(ty) || ty === "") {
		return '<span style="text-align:right;display:block;float:left;padding-right:10px;"></span><span style="float:center;color:#AAA;font-size:10px;text-align:left;"><i class="glyphicon glyphicon-minus"></i></span>';
	} else if (isNaN(ly) || ly === ""||ly==null) {
		return '<span style="text-align:right;display:block;float:left;padding-right:10px;">'
				+ formatNumber(ty)
				+ '</span> <span style="float:right;color:#AAA;font-size:10px;text-align:left;"><i class="glyphicon glyphicon-minus"></i></span>';
	} else if (ty > ly) {
		var differ = ty - ly + "";
		return '<span style="text-align:right;display:block;float:left;padding-right:10px;">'
				+ formatNumber(ty)
				+ '</span> <span style = "display:none">&nbsp;+</span> <span style="float:right;color:red;font-size:8px;text-align:left;"><i class="glyphicon glyphicon-arrow-up"></i>'
				+ (differ.indexOf('.') == -1 ? ty - ly : (ty - ly).toFixed(2))
				+ '</span>';
	} else if (ty < ly) {
		var differ = ly - ty + "";
		return '<span style="text-align:right;display:block;float:left;padding-right:10px;">'
				+ formatNumber(ty)
				+ '</span> <span style = "display:none">&nbsp;-</span> <span style="float:right;color:green;font-size:8px;text-align:left;"><i class="glyphicon glyphicon-arrow-down"></i>'
				+ (differ.indexOf('.') == -1 ? ly - ty : (ly - ty).toFixed(2))
				+ '</span>';
	} else if (ty == ly) {
		return '<span style="text-align:right;display:block;float:left;padding-right:10px;">'
				+ formatNumber(ty)
				+ '</span> <span  style="float:right;color:orange;font-size:10px;text-align:left;"><i class="glyphicon glyphicon-minus"></i></span>';
	}
}

/**
 * 
 * @ Discription:比较两个数值，返回升降状态
 * @Autor ：liuhongjun
 * @param thisYearValue
 * @param lastYearValue
 * @returns
 * any
 * drgsCommon.js
 * 2017年6月12日下午6:41:50
 */
function compareValue(thisYearValue, lastYearValue) {
	var ty = transformFloat(thisYearValue);
	var ly = transformFloat(lastYearValue);
	if (isNaN(ty)) {
		return '<span style="text-align:right;display:block;float:left;padding-right:10px;"></span><span style="float:center;color:#AAA;font-size:10px;text-align:left;"><i class="glyphicon glyphicon-minus"></i></span>';
	}
	if (isNaN(ly) || ly == 0) {
		return '<span class= "number" style="text-align:right;display:block;float:left;padding-right:10px;">'
				+ formatNumber(ty)
				+ '</span> <span style="float:right;color:#AAA;font-size:10px;text-align:left;"><i class="glyphicon glyphicon-minus"></i></span>';
	}
	if (ty > ly && ly != 0) {
		return '<span class= "number" style="text-align:right;display:block;float:left;padding-right:10px;">'
				+ formatNumber(ty)
				+ '</span> <span style = "display:none">&nbsp;+</span> <span style="float:right;color:red;font-size:8px;text-align:left;"><i class="glyphicon glyphicon-arrow-up"></i>'
				+ ((ty - ly) * 100 / ly).toFixed(2) + '%</span>';
	} else if (ty < ly) {
		return '<span class= "number" style="text-align:right;display:block;float:left;padding-right:10px;">'
				+ formatNumber(ty)
				+ '</span> <span style = "display:none">&nbsp;-</span> <span style="float:right;color:green;font-size:8px;text-align:left;"><i class="glyphicon glyphicon-arrow-down"></i>'
				+ ((ly - ty) * 100 / ly).toFixed(2) + '%</span>';
	} else if (ty == ly) {
		return '<span class= "number" style="text-align:right;display:block;float:left;padding-right:10px;">'
				+ formatNumber(ty)
				+ '</span> <span  style="float:right;color:orange;font-size:10px;text-align:left;"><i class="glyphicon glyphicon-minus"></i></span>';
	}
	return '<span class= "number" style="text-align:right;display:block;float:left;padding-right:10px;">'
			+ formatNumber(ty) + '</span>';
}
/**
 * 
 * @ Discription:表格比较值返回上下箭头
 * @Autor ：liuhongjun
 * @param thisYearValue
 * @param lastYearValue
 * @returns
 * any
 * drgsCommon.js
 * 2017年6月12日下午6:42:04
 */
function gridcompareValue(thisYearValue, lastYearValue) {
	var ty = transformFloat(thisYearValue);
	var ly = transformFloat(lastYearValue);
	if (isNaN(ty) || isNaN(ly) || ly == 0) {
		return '<span style="float:center;color:#AAA;font-size:10px;text-align:left;"><i class="glyphicon glyphicon-minus"></i></span>';
	}
	if (ty > ly) {
		return '<span style = "display:none">&nbsp;+</span> <span style="float:center;color:red;font-size:8px;text-align:left;"><i class="glyphicon glyphicon-arrow-up"></i>'
				+ ((ty - ly) * 100 / ly).toFixed(2) + '%</span>';
	} else if (ty < ly) {
		return '<span style = "display:none">&nbsp;-</span> <span style="float:center;color:green;font-size:8px;text-align:left;"><i class="glyphicon glyphicon-arrow-down"></i>'
				+ ((ly - ty) * 100 / ly).toFixed(2) + '%</span>';
	} else if (ty == ly) {
		return '<span style="float:center;color:orange;font-size:10px;text-align:left;"><i class="glyphicon glyphicon-minus"></i></span>';
	}
	return '<span  style="float:center;color:orange;font-size:10px;text-align:left;"><i class="glyphicon glyphicon-minus"></i></span>';
}//修改该方法的比较条件

/**
 * 
 * @ Discription:表格比较值返回上下箭头,,比率类flx
 * @Autor ：liuhongjun
 * @param thisYearValue
 * @param lastYearValue
 * @returns
 * any
 * drgsCommon.js
 * 2017年6月12日下午6:42:14
 */
function gridcompareValuePercent(thisYearValue, lastYearValue) {
	var ty = (typeof(thisYearValue) == 'undefined' || thisYearValue == null)
			? null
			: parseFloat(thisYearValue);
	var ly = (typeof(lastYearValue) == 'undefined' || lastYearValue == null)
			? null
			: parseFloat(lastYearValue);
	if (ty == null || ly == null || ly == 0) {
		return '<span  style="float:center;color:#AAA;font-size:10px;text-align:left;"><i class="glyphicon glyphicon-minus"></i></span>';
	}
	if (ty > ly) {
		return '<span style = "display:none">&nbsp;+</span> <span style="float:center;color:red;font-size:8px;text-align:left;"><i class="glyphicon glyphicon-arrow-up"></i>'
				+ (ty - ly).toFixed(2) + '</span>';
	} else if (ty < ly) {
		return '<span style = "display:none">&nbsp;-</span> <span style="float:center;color:green;font-size:8px;text-align:left;"><i class="glyphicon glyphicon-arrow-down"></i>'
				+ (ly - ty).toFixed(2) + '</span>';
	} else if (ty == ly) {
		return '<span  style="float:center;color:orange;font-size:10px;text-align:left;"><i class="glyphicon glyphicon-minus"></i></span>';
	}
	return '<span  style="float:center;color:#AAA;font-size:10px;text-align:left;"><i class="glyphicon glyphicon-minus"></i></span>';
}


/**
 * 
 * @ Discription:总费用、医保费用、药品费用、材料费等指标处理
 * @Autor ：liuhongjun
 * @param thisYearValue
 * @param lastYearValue
 * @returns
 * any
 * drgsCommon.js
 * 2017年6月12日下午6:42:31
 */
function compareFeeValue(thisYearValue, lastYearValue) {
	var ty = (typeof(thisYearValue) == 'undefined' || thisYearValue == null)
			? null
			: parseFloat(thisYearValue);
	var ly = (typeof(lastYearValue) == 'undefined' || lastYearValue == null)
			? null
			: parseFloat(lastYearValue);
	if (ty == undefined) {
		return '-';
	}
	if (ly == null || ly == 0) {
		if (ty > 10000) {
			return '<span>' + (ty / 10000).toFixed(2) + '万元</span>';
		}
		return '<span style="text-align:right;display:block;float:left;padding-right:10px;">'
				+ ty + '</span>';
	} else if (ty > ly && ly != 0) {
		if (ty > 10000) {
			return '<span>'
					+ (ty / 10000).toFixed(2)
					+ '万元</span> <span style = "display:none">&nbsp;+</span> <span style="float:right;color:red;font-size:8px;text-align:left;"><i class="glyphicon glyphicon-arrow-up"></i>'
					+ ((ty - ly) * 100 / ly).toFixed(2) + '%</span>';
		}
		return '<span style="text-align:right;display:block;float:left;padding-right:10px;">'
				+ ty
				+ '</span> <span style = "display:none">&nbsp;+</span> <span style="float:right;color:red;font-size:8px;text-align:left;"><i class="glyphicon glyphicon-arrow-up"></i>'
				+ ((ty - ly) * 100 / ly).toFixed(2) + '%</span>';
	} else if (ty < ly) {
		if (ty > 10000) {
			return '<span>'
					+ (ty / 10000).toFixed(2)
					+ '万元</span> <span style = "display:none">&nbsp;-</span> <span style="float:right;color:green;font-size:8px;text-align:left;"><i class="glyphicon glyphicon-arrow-down"></i>'
					+ ((ly - ty) * 100 / ly).toFixed(2) + '%</span>';
		}
		return '<span style="text-align:right;display:block;float:left;padding-right:10px;">'
				+ ty
				+ '</span> <span style = "display:none">&nbsp;-</span> <span style="float:right;color:green;font-size:8px;text-align:left;"><i class="glyphicon glyphicon-arrow-down"></i>'
				+ ((ly - ty) * 100 / ly).toFixed(2) + '%</span>';
	} else if (ty == ly) {
		return '<span style="text-align:right;display:block;float:left;padding-right:10px;">'
				+ ty
				+ '</span> <span  style="float:right;color:orange;font-size:10px;text-align:left;"><i class="glyphicon glyphicon-minus"></i></span>';
	}
}
/**
 * 
 * @ Discription:弹出框趋势图
 * @Autor ：liuhongjun
 * @param ccode
 * @param title
 * @param type
 * @param quotaCode
 * @param quotaName
 * @returns
 * any
 * drgsCommon.js
 * 2017年6月12日下午6:43:31
 */
function trend(ccode, title, type, quotaCode, quotaName) {
	if (title == "1") {
		title = ccode;
	}
	if (!title)
		title = "弹出窗口";
	var depGroupCode = paramTabPage[tabId].depGroupCode
			? paramTabPage[tabId].depGroupCode
			: "";
	var deps = paramTabPage[tabId].deps ? paramTabPage[tabId].deps : "";
	var depCode = paramTabPage[tabId].depCode
			? paramTabPage[tabId].depCode
			: "";
	var groupName = paramTabPage[tabId].groupName
			? paramTabPage[tabId].groupName
			: "";

	var protomedicus = paramTabPage[tabId].protomedicus
			? paramTabPage[tabId].protomedicus
			: "";// 主任医师
	var physician = paramTabPage[tabId].physician
			? paramTabPage[tabId].physician
			: "";// 主治医师
	var resident = paramTabPage[tabId].resident
			? paramTabPage[tabId].resident
			: "";// 住院医师

	var mdcCode = paramTabPage[tabId].mdcCode
			? paramTabPage[tabId].mdcCode
			: "";
	var adrgCode = paramTabPage[tabId].adrgCode
			? paramTabPage[tabId].adrgCode
			: "";
	var drgCode = paramTabPage[tabId].drgCode
			? paramTabPage[tabId].drgCode
			: "";
	var wardCode = paramTabPage[tabId].wardCode
			? paramTabPage[tabId].wardCode
			: "";
	switch (type) {
		case "depGroup" :
			depGroupCode = ccode;
			break;
		case "dep" :
			depCode = ccode;
			break;
		case "ward" :
			wardCode = ccode;
			break;
		case "clinic" :
			groupName = ccode;
			break;
		case "protomedicus" :// 主任医师
			protomedicus = ccode;
			break;
		case "physician" :// 主治医师
			physician = ccode;
			break;
		case "resident" :// 住院医师
			resident = ccode;
			break;
		case "mdc" :
			mdcCode = ccode;
			break;
		case "adrg" :
			adrgCode = ccode;
			break;
		case "drgs" :
			drgCode = ccode;
			break;
	}
	$.post(contextPath + '/pages/common/top-dialog.jsp').done(function(data) {
		var dialog = $(data);
		dialog.find(".modal-title").html(title + "指标相关信息");
		dialog.modal({
					keyboard : false
				}).on({
			'hidden.bs.modal' : function() {
				$(this).remove();
			},
			'shown.bs.modal' : function() {
				var map = drgUI.setAjaxData(tabId);
				map.monitorType = type;
				map.quotaCode = quotaCode;
				map.isGetCc = '0';
				map.pardepgroupCode = depGroupCode;
				map.deps = deps;
				map.pardepCode = depCode;
				map.pargroupName = groupName;
				map.parwardCode = wardCode;
				map.protomedicus = protomedicus;
				map.physician = physician;
				map.resident = resident;
				map.parmdcCode = mdcCode;
				map.paradrgCode = adrgCode;
				map.pardrgCode = drgCode;
				$.post(contextPath + "/DrgsIndexCal/findTrendData.dhc",
						map).done(function(result) {
						if (result.success) {
								var data = result.data;
								for (var i = 0; i < data.length; i++) {
									if (data[i].QuotaValue == null) {
										data[i].QuotaValue = 0;
									}
								}
								var lines = [{
											"code" : "QuotaValue",
											"desc" : quotaName,
											"data" : []
										}];
								var datas = [];
								datas.push(data);
								var chartParams = {
									titleShow : true,
									legendPosition : 'bottom',
									isDataZoom : true,
									autoWidth : true,
									autoHeight : 'auto',
									heightRatio : 0.4
								};
								lineChartBasic(dialog.find(".echartscq"),lines, datas, quotaName + "趋势图", '',chartParams);
							}
				});
			}
		});
	});
}
/**
 * 
 * @ Discription:去掉变量中特殊字符
 * @Autor ：liuhongjun
 * @param num
 * @returns
 * any
 * drgsCommon.js
 * 2017年6月12日下午6:45:08
 */
function transformFloat(num) {
	// 如果传入的数字有千位分隔符，先去掉
	num = num + '';
	num = num.replace(',', '');
	num = num.replace('，', '');
	num = num.replace(' ', '');
	return parseFloat(num);
}
/**  
* 求两个集合的补集  
*/  
array_complement = function(a, b, key){  
     return array_minus(array_union(a, b, key), array_intersect(a, b, key), key);  
}; 
/**  
* 求两个集合的交集  
*/  
array_intersect = function(a, b, key){  
	var ra = [];
	a = array_uniquelize(a, key);
	for(var o in a){
		if(array_contains(b, a[o], key)){
			ra.push(a[o]);
		}
	}
  return ra;  
};  
/**  
* 求两个集合的差集  
*/  
array_minus = function(a, b, key){ 
	var ra = [];
	a = array_uniquelize(a, key);
	for(var o in a){
		if(!array_contains(b, a[o], key)){
			ra.push(a[o]);
		}
	}
  return ra; 
};  
/**  
* 求两个集合的并集   
*/  
array_union = function(a, b, key){  
		return array_uniquelize(a.concat(b), key);  
};  
//数组包含一个元素,某一个key值相等
array_contains = function(a, item, key){
     for(i=0;i<a.length;i++){
         if(a[i][key]==item[key]){return true;}
     }
     return false;
};
 
/**  
* 得到一个数组不重复的元素集合<br/>  
* 唯一化一个数组,按主键key唯一识别
* @returns {Array} 由不重复元素构成的数组  
*/  
array_uniquelize = function(a, key){  
     var ra = new Array();
     if(a){
	     for(var i = 0; i < a.length; i ++){  
	         if(!array_contains(ra, a[i], key)){  
	            ra.push(a[i]);  
	         }  
	     } 
     } 
     return ra;  
}; 
//js数组查找某元素位置方法,改//lileizheng
var array_indexOf= function(array, val, attr) {
	if(array){
		for (var i = 0; i < array.length; i++) {
			if (attr && array[i][attr] == val) {
				return i;
			}else if (!attr && array[i] == val) {
				return i;
			}
		}	
	}
	return -1;
};
//js数组移除单元素
var array_remove = function(array, val) {
	var index = array_indexOf(array, val);
	if (index > -1) {
		array.splice(index, 1);
	}
};
//js数组移除object元素
var array_removeAttr = function(array, attr, val) {
	var index = array_indexOf(array, val, attr);
	if (index > -1) {
		array = array.splice(index, 1);
	}
	return array;
};

/**
 * 过滤数组中指定属性的值
 * @@param data 对象数组
 * @@param property 属性
 * @@param propertyVal 数组
 * @@returns
 * @any
 * @ Discription:
 */
var array_filter = function (data, property, propertyVal) {
	var array = data.filter(function(obj) {
					return $.inArray(obj[property], propertyVal) >= 0
				});
	return array;
}
/**
 * 
 * @ Discription:根据比较类型获取时间
 * @Autor ：liuhongjun
 * @param compareType
 * @returns
 * any
 * drgsCommon.js
 * 2017年6月12日下午6:47:11
 */
function getTime(compareType) {
	var cur = $(".time_id").html();
	cur = cur.replace("(", "");
	cur = cur.replace(")", "");
	if (cur.indexOf("~") < 0) {// 不包含~
		if (cur.indexOf("-") < 0) {
			cur = cur.split(".");
			var year = parseInt(cur[0], "10");// 年
			var month = parseInt(cur[1], "10");// 月
			if (compareType == "year") {
				year = year - 1;
			} else if (compareType == "month") {
				month = month - 1;
				if (month == 0) {
					month = 12;
					year = year - 1;
				}
			}
			if (month < 10) {
				month = "0" + month;
			}
			return "(" + year + "." + month + ")";
		} else {// 当监测时间类型为custom,datafrom与datato相等时，传入的值如2017-07，需做兼容处理，add by
				// wen
			cur = cur.split("-");
			var year = parseInt(cur[0], "10");// 年
			var month = parseInt(cur[1], "10");// 月
			if (compareType == "year") {
				year = year - 1;
			} else if (compareType == "month") {
				month = month - 1;
				if (month == 0) {
					month = 12;
					year = year - 1;
				}
			}
			if (month < 10) {
				month = "0" + month;
			}
			return "(" + year + "-" + month + ")";
		}

	} else {// 包含~
		cur = cur.split("~");
		var start = cur[0];
		var end = cur[1];
		if (start.indexOf("-") < 0) {
			start = start.split(".");
			end = end.split(".");
			var startyear = parseInt(start[0], "10");// 年
			var startmonth = parseInt(start[1], "10");// 月
			var endyear = parseInt(end[0], "10");// 年
			var endmonth = parseInt(end[1], "10");// 月
			if (compareType == "year") {
				startyear = startyear - 1;
				endyear = endyear - 1;
			} else if (compareType == "month") {
				startmonth = startmonth - 1;
				if (startmonth == 0) {
					startmonth = 12;
					startyear = startyear - 1;
				}
				endmonth = endmonth - 1;
				if (endmonth == 0) {
					endmonth = 12;
					endyear = endyear - 1;
				}
			}
			if (startmonth < 10) {
				startmonth = "0" + startmonth;
			}
			if (endmonth < 10) {
				endmonth = "0" + endmonth;
			}
			return "(" + startyear + "." + startmonth + "~" + endyear + "."
					+ endmonth + ")";
		} else {
			start = start.split("-");
			end = end.split("-");
			var startyear = parseInt(start[0], "10");// 年
			var startmonth = parseInt(start[1], "10");// 月
			var endyear = parseInt(end[0], "10");// 年
			var endmonth = parseInt(end[1], "10");// 月
			if (compareType == "year") {
				startyear = startyear - 1;
				endyear = endyear - 1;
			} else if (compareType == "month") {
				startmonth = startmonth - 1;
				if (startmonth == 0) {
					startmonth = 12;
					startyear = startyear - 1;
				}
				endmonth = endmonth - 1;
				if (endmonth == 0) {
					endmonth = 12;
					endyear = endyear - 1;
				}
			}
			if (startmonth < 10) {
				startmonth = "0" + startmonth;
			}
			if (endmonth < 10) {
				endmonth = "0" + endmonth;
			}
			return "(" + startyear + "-" + startmonth + "~" + endyear + "-"
					+ endmonth + ")";
		}
	}
}
/**
 * 
 * @ Discription:条件显示框
 * @Autor ：liuhongjun
 * @param isShow 是否显示条件
 * @param _v1=1隐藏第1组参数
 * @param _v2=1隐藏第2组参数
 * @param _v3=1隐藏第3组参数
 * @param _v4=1隐藏第4组参数(V4中存在四个子条件)
 * @returns
 * any
 * drgsCommon.js
 * 2017年7月9日下午8:11:03
 */
function showCondition(isShow, _v1, _v2, _v3, _v4) {
	paramTabPage[tabId].isShowCo = false;// 附默认值
	if (isShow) {
		paramTabPage[tabId].isShowCo = true;
	}
	paramTabPage[tabId]._v1 = _v1;
	paramTabPage[tabId]._v2 = _v2;
	paramTabPage[tabId]._v3 = _v3;
	paramTabPage[tabId]._v4 = _v4;
	paramTabPage[tabId]._v4_index = $("#searchcq").children().eq(3)
			.find("div.ci a.active").index();
	if (paramTabPage[tabId] && paramTabPage[tabId].isShowCo) {
		$("#searchbtncq").fadeIn();
		for (var i = 0; i < 4; i++) {
			$("#searchcq").children().eq(i).fadeIn();
		}
		if (_v1 == 0) {
			$("#searchcq").children().eq(0).fadeOut();
		}
		if (_v2 == 0) {
			$("#searchcq").children().eq(1).fadeOut();
		}
		if (_v3 == 0) {
			$("#searchcq").children().eq(2).fadeOut();
		}
		if (_v4 && _v4.length == 0) {
			$("#searchcq").children().eq(3).fadeOut();
		} else if (_v4) {
			for (var o = 0; o < 5; o++) {
				$("#searchcq").children().eq(3).find("a").eq(o).css("display",
						"");
			}
			var _v4_0 = _v4[0];
			var _v4_1 = _v4[1];
			var _v4_2 = _v4[2];
			var _v4_3 = _v4[3];
			var _v4_4 = _v4[4];
			var _v4_5 = _v4.length == 6 ? _v4[5] : 0;
			if (_v4_0 == 0) {
				$("#searchcq").children().eq(3).find("a").eq(0).css("display",
						"none");
			}
			if (_v4_1 == 0) {
				$("#searchcq").children().eq(3).find("a").eq(1).css("display",
						"none");
			}
			if (_v4_2 == 0) {
				$("#searchcq").children().eq(3).find("a").eq(2).css("display",
						"none");
			}
			if (_v4_3 == 0) {
				$("#searchcq").children().eq(3).find("a").eq(3).css("display",
						"none");
			}
			if (_v4_4 == 0) {
				$("#searchcq").children().eq(3).find("a").eq(4).css("display",
						"none");
			}
			if (_v4_5 == 1) {
				$("#searchcq").children().eq(3).find("a").eq(5).css("display",
						"");
			} else {
				$("#searchcq").children().eq(3).find("a").eq(5).css("display",
						"none");
			}
			var vfour = false;
			for (var o = 0; o < 6; o++) {
				if ($("#searchcq").children().eq(3).find("a").eq(o)
						.css("display") != "none"
						&& $("#searchcq").children().eq(3).find("a").eq(o)
								.hasClass("active")) {
					vfour = true;
					break;
				}
			}
			if (!vfour) {
				for (var o = 0; o < 6; o++) {
					$("#searchcq").children().eq(3).find("a").eq(o)
							.removeClass("active");
					if ($("#searchcq").children().eq(3).find("a").eq(o)
							.css("display") != "none") {
						$("#searchcq").children().eq(3).find("a").eq(o)
								.addClass("active");
						break;
					}
				}
			}
			paramTabPage[tabId].compareType = $("#searchcq").children().eq(3)
					.find("div.ci a.active").attr("data-value");
		} else {
			for (var o = 0; o < 6; o++) {
				$("#searchcq").children().eq(3).find("a").eq(o).css("display",
						"");
			}
			$("#searchcq").children().eq(3).find("a").eq(2).css("display",
					"none");// 隐藏院内均值
			$("#searchcq").children().eq(3).find("a").eq(5).css("display",
					"none");
		}

		// 设置查询条件后面的监测时间显示
		var classflag0 = $("#searchcq").children().eq(2).find("a").eq(0)
				.attr("class");
		var classflag1 = $("#searchcq").children().eq(2).find("a").eq(1)
				.attr("class");
		var classflag2 = $("#searchcq").children().eq(2).find("a").eq(2)
				.attr("class");
		if (classflag2 != "active") {
			$("#searchcq").children().eq(2).find("div.ci a").eq(2).css(
					"display", "");
		}
		if (classflag0 == "active") {
			$(".time_id").html("("
					+ $("#searchcq").children().eq(2).find("a").eq(0).html()
					+ ")");
		} else if (classflag1 == "active") {
			$(".time_id").html("("
					+ $("#searchcq").children().eq(2).find("a").eq(1).html()
					+ ")")
		} else if (classflag2 == "active") {
			var dateFrom = $("#date-from").val().replace('.', '-')//替换点，避免自定义时间结束日期转格式报错的问题
			var dateTo = $("#date-to").val().replace('.', '-')
			if (dateFrom == dateTo) {
				$(".time_id").html("(" + dateFrom + ")")
			} else {
				$(".time_id").html("(" + dateFrom + "~" + dateTo + ")")
			}
		}
	} else {
		$("#searchbtncq").fadeOut();
	}
}
/**
 *  @ Discription:获取字典值
 * @Autor ：liuhongjun
 * @param code
 *            字典code
 * @param value
 *            字典小类值
 * @returns 返会字典描述 any drgsCommon.js 2017年7月15日上午9:43:21
 */
function getDicDesc(code,value){
		var dicDesc='未定义';
		var data=diction[code];
		for(var i in data){
			if(data[i].DICVALUE==value){
				dicDesc=data[i].DICDESC;
			}
		}
		return dicDesc;
}
/**
 * 
 * @ Discription:获取字典中的json格式
 * @Autor ：liuhongjun
 * @param code
 * @returns
 * any
 * drgsCommon.js
 * 2017年7月16日下午8:09:54
 */
function getDicObj(code){
	if(value==undefined){
		return diction[code];
	}else{
		return null;
	}
}
/**
 * 
 * @ Discription:每十字符添加一个换行符
 * @Autor ：WENYI  
 * @param obj  文本
 * 2017年7月17日下午6:41:03
 */
function linefeedText(obj, len) {
	len = len ? len : 60;
	var str = '';
	var m = 1;
	if (obj != null && obj.length > len) {
		for (var i = 0; i < obj.length; i += len) {
			if ((obj.length - m * len) < 0) {
				str = str + obj.substring((m - 1) * len) + '<br>';
			} else {
				str = str + obj.substring((m - 1) * len, m * len) + '<br>';
			}
			m++;
		}
	} else {
		str = obj;
	}
	return str;
}
/**
 * 
 * @@param this_tabId
 * @@returns
 * @any
 * @ Discription:添加页面的遮罩事件
 * @drgsCommon.js
 */
function showOverlay(this_tabId) {
	$(document).ajaxStop(function() {
				$(document).unbind('ajaxStop');
			});
}

/**
 * 
 * @ Discription:双向选择列表公共方法
 * @Autor ：WENYI
 * @param container容器
 * @param lListData 左边列表数据
 * @param rListData 右边列表数据
 * @param name 存储数据编码的字段
 * @param name 存储数据描述的字段
 * 2017年8月10日上午8:43:31
 */
function selectListCustom(container, lListData, rListData, code, name) {
	var listContainer = '<div id="selectListCustom" class="list-select" style="position: relative;">';
	var listTitle = '<div class="list-title"><input class="selectFilter" placeholder="输入搜索"/></div>';
	var listLeftContent = '<div class="item-box left-box">';
	if (lListData != undefined && lListData != '') {
		for (var o in lListData) {
			listLeftContent += '<span class="item" data-value='
					+ lListData[o][code] + '>' + lListData[o][name] + '</span>';
		}
	}
	listLeftContent += '</div>';
	var listCenterContent = '<div class="center-box">'
			+ '<button class="add-one add" title="添加选中项">&gt;</button>'
			+ '<button class="add-all add" title="添加全部">&gt;&gt;</button>'
			+ '<button class="remove-one remove" title="移除选中项">&lt;</button>'
			+ '<button class="remove-all remove" title="移除全部">&lt;&lt;</button>'
			+ '</div>';
	var listRightContent = '<div class="item-box right-box">';
	if (rListData != undefined && rListData != '') {
		for (var o in rListData) {
			listRightContent += '<span class="item" data-value='
					+ rListData[o][code] + '>' + rListData[o][name] + '</span>';
		}
	}
	listRightContent += '</div>';
	var listBody = '<div class="list-body">' + listLeftContent
			+ listCenterContent + listRightContent + '</div>';
	listContainer += listTitle + listBody;
	container.append(listContainer);

	container.find(".list-body .left-box,.list-body .right-box").on('click',
			'.item', function() {
				$(this).addClass("selected-item");
			});
	container.find(".list-body .center-box").on('click', '.add-one',
			function() {
				container.find(".list-body .left-box").find('.selected-item')
						.appendTo(".list-body .right-box")
						.removeClass('selected-item');
			});
	container.find(".list-body .center-box").on('click', '.add-all',
			function() {
				container.find(".list-body .left-box").find('.item')
						.appendTo(".list-body .right-box")
						.removeClass('selected-item');
			});
	container.find(".list-body .center-box").on('click', '.remove-one',
			function() {
				container.find(".list-body .right-box").find('.selected-item')
						.appendTo(".list-body .left-box")
						.removeClass('selected-item');
			});
	container.find(".list-body .center-box").on('click', '.remove-all',
			function() {
				container.find(".list-body .right-box").find('.item')
						.appendTo(".list-body .left-box")
						.removeClass('selected-item');
			});

	container.find(".list-body .left-box").on('dblclick', '.item', function() {
		$(this).appendTo(container.find(".list-body .right-box"))
				.removeClass('selected-item');
	});

	container.find(".list-body .right-box").on('dblclick', '.item', function() {
		$(this).appendTo(container.find(".list-body .left-box"))
				.removeClass('selected-item');
	});
	container.find('.list-select .list-title .selectFilter').on('input',
			function() {
				var text = $(this).val();
				var isFind = false;
				container.find(".list-body .left-box .noItem").remove();
				container.find(".list-body .left-box .item").each(function() {
							if ($(this).html().indexOf(text) >= 0) {
								$(this).css('display', 'block');
								isFind = true;
							} else {
								$(this).css('display', 'none');
							}
						});
				if (!isFind) {
					container
							.find(".list-body .left-box")
							.append('<span class="noItem" style="margin:5px 0 0 10px;display:block;color:#FF6666">无符合条件数据…</span>')
				}
			});
}

/**
 * 
 * @@param listMap 排序的licesne
 * @@param sortFile 排序字段
 * @@param sortType  升序降序 asc desc
 * @@returns
 * @any
 * @ Discription:
 * @ywcHomePage.js
 */
function sortListMap(listMap, sortFile, sortType) {
	for (var i = 0; i < listMap.length - 1; i++) {
		for (var j = 0; j < listMap.length - 1 - i; j++) {
			var valueO = listMap[j][sortFile];
			var valueN = listMap[j + 1][sortFile];
			if (sortType === "asc" ? valueO > valueN : valueO < valueN) {
				var $temp = listMap[j];
				listMap[j] = null;
				listMap[j] = listMap[j + 1];
				listMap[j + 1] = null;
				listMap[j + 1] = $temp;
			}

		}
	}
	return listMap;
}
/**
 * 返回字符串的长度
 * @@param str
 * @@returns {Number}
 * @Number
 * @ Discription:
 * @drgsCommon.js
 */
function lengthOfSting(str) {
	var l = str.length;
	var blen = 0;
	for(i=0; i<l; i++) {
		if ((str.charCodeAt(i) & 0xff00) != 0) {
			blen ++;
		}
			blen ++;
	}
	return blen ;
} 

// 对Date的扩展，将 Date 转化为指定格式的String
// 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符， 
// 年(y)可以用 1-4 个占位符，毫秒(S)只能用 1 个占位符(是 1-3 位的数字) 
// 例子： 
// (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423 
// (new Date()).Format("yyyy-M-d h:m:s.S")      ==> 2006-7-2 8:9:4.18 
Date.prototype.Format = function(fmt) { // author: meizz
	var o = {
		"M+" : this.getMonth() + 1, // 月份
		"d+" : this.getDate(), // 日
		"h+" : this.getHours(), // 小时
		"m+" : this.getMinutes(), // 分
		"s+" : this.getSeconds(), // 秒
		"q+" : Math.floor((this.getMonth() + 3) / 3), // 季度
		"S" : this.getMilliseconds()
		// 毫秒
	};
	if (/(y+)/.test(fmt))
		fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4
						- RegExp.$1.length));
	for (var k in o)
		if (new RegExp("(" + k + ")").test(fmt))
			fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1)
							? (o[k])
							: (("00" + o[k]).substr(("" + o[k]).length)));
	return fmt;
} 
/**
 * 
 * @param {} id
 * @param {} patientName
 * 跳转病例病案首页
 */
function medicalRecord(id,patientName){
	openTab('/pages/yizheng/qcPatientList.jsp',patientName+'|病案首页', 'patient'+id,'patient'+id,{patientId:id});
}


/**
 * 判断当前科室(科室组 病区)是否是医师所在科室((科室组 病区))
 * @param codeNow 医师表维护的科室(科室组,病区信息)
 * @param doccode 当前医师
 * @returns 
 */
function isBelongTo(codeNow,doccode) {
	var code = "" ;
	var param=drgUI.setAjaxData(tabId);
	if(param.parwardCode) {
		code = param.parwardCode ;
	} else if (param.pardepCode) {
		code = param.pardepCode ;
	} else if (param.pardepgroupCode) {
		code = param.pardepgroupCode ;
	}
	if(codeNow) {
		codeNow = codeNow.split(",") ;
	} else {
		console.warn(doccode+" 编码的医师信息维护不全") ;
		return false ;
	}
	if(jQuery.inArray(code, codeNow)>-1) {
		return true ;
	} else {
		return false;
	}
}

/**
 * 初始化复制，将查询条件的参数传递给页面参数对象paramTabPage[tabId]
 * @param {} tabId
 */
function loadTabParam(tabId) {
	var pType = $("#searchcq").children().eq(0).find("div.ci a.active")
			.attr("data-value");// 病例类型
	var compareType = $("#searchcq").children().eq(3).find("div.ci a.active")
			.attr("data-value");// 比较类型
	var msCode = $("#searchcq").children().eq(3).find("div.ci a.active")
			.attr("code-data")// 标杆表和绩效比选择的比较对象
	var hospCode = decodeURI($.getUrlParam('hospCode'));
	if (hospCode == 'null') {
		hospCode = selectedHospCode;
	}
	var dateFrom = "";
	var dateTo = "";
	var mrLot = "";
	// 采用最新年度配置后,mrLot直接废弃
	var mrType = $("#searchcq").children().eq(2).find("div.ci a.active")
			.attr("data-type");
	if (mrType == "custom") {
		dateFrom = $("#date-from").val().replace('.', '-');
		dateTo = $("#date-to").val().replace('.', '-');
	} else {
		dateFrom = $("#searchcq").children().eq(2).find("div.ci a.active")
				.attr("data-value-f");
		dateTo = $("#searchcq").children().eq(2).find("div.ci a.active")
				.attr("data-value-t");
	}
	if (paramTabPage[tabId]) {
		paramTabPage[tabId] = $.extend({}, paramTabPage[tabId], {
			pType : pType,
			mrLot : mrLot,
			mrType : mrType,
			dateFrom : dateFrom,
			dateTo : dateTo,
			compareType : compareType,
			msCode : msCode,
			hospCode : hospCode,
			isGetCc : 1
				// 默认获取比较值：0：不获取比较值1：获取比较值，2：仅获取比较值
			})
	} else {
		paramTabPage[tabId] = {
			pType : pType,
			mrLot : mrLot,
			mrType : mrType,
			dateFrom : dateFrom,
			dateTo : dateTo,
			compareType : compareType,
			msCode : msCode,
			hospCode : hospCode,
			isGetCc : 1
			// 默认获取比较值：0：不获取比较值1：获取比较值，2：仅获取比较值
		};
	}
}
 /**
  * 获取地址栏参数
  */
(function($) {
	$.getUrlParam = function(name) {
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
		var r = window.location.search.substr(1).match(reg);
		if (r != null)
			return unescape(r[2]);
		return null;
	}
})(jQuery);

/**
 * 随机字符串
 * @param {} len
 * @return {}
 */
function getRandomString(len) {  
    len = len || 32;  
    var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; // 默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1  
    var maxPos = $chars.length;  
    var pwd = '';  
    for (i = 0; i < len; i++) {  
        pwd += $chars.charAt(Math.floor(Math.random() * maxPos));  
    }  
    return pwd;  
} 

/**
 * 条件查询模态框
 */
var SwitchDialog = function (dialog){
	this.dialog = dialog;
	this.callback = [];
	this.loadData = [];
}
SwitchDialog.prototype = {
	add: function(option){
		var item = $('<section class="item '+option.size+'">'
						+'<div class="item-header"><i class="fa fa-'+option.icon+' fa-lg"></i><span>'+option.title+'</span></span></div>'
						+'<div class="item-body">'+option.content+'</div>'
					+'</section>');
		this.dialog.find('.modal-body').append(item);
		if(option.callback){
			this.callback.push(option.callback);
		}
		if(option.loadData){
			this.loadData.push(option.loadData);
		}
		return this;
	},
	callbackInvoke: function(){
		for ( var i in this.callback) {
			this.callback[i].call();
		}
		//return this;
	},
	loadDataInvoke: function(){
		for ( var i in this.loadData) {
			this.loadData[i].call();
		}
		return this;
	},
	show: function(){
		this.dialog.modal('show');
	}
}

/**
 * 查询科室组方法
 */
function getDepGroupByCode() {
	//获取所有科室组列表
	var dtd = $.ajax({
		url : contextPath + "/DrgsIndexCal/getDepGroupByCode.dhc",
		type : "post",
		dataType : "json",
		async : true,
		data:{'hospCode': paramTabPage[tabId].hospCode,'depGroupCode': '', 'depCode':'',  'wardCode':'' },
		success : function(data) {
			dicDataTemp.hospInfo.depGroupData = data.data ;
		}
	});
	return dtd ;
}

/**
 * 查询科室方法
 */
function findAllDepByHospCode() {
//	//获取所有科室组列表
	var param=drgUI.setAjaxData(tabId);
	param.pardepCode = "" ;
	param.pardepgroupCode = "" ;
	param.deps = "" ;
	var dtd = $.ajax({
		url : contextPath + "/DrgsIndexCal/findAllDepByHospCode.dhc",
		type : "post",
		dataType : "json",
		async : true,
		data:param,
		success : function(data) {
			dicDataTemp.hospInfo.depData = data.data ;
		}
	})
	return dtd ;
}


/**
 * 查询病区方法
 */
function getWardByCode() {
	//获取所有科室组列表 
	var dtd = $.ajax({
		url : contextPath + "/DrgsIndexCal/getWardByCode.dhc",
		type : "post",
		dataType : "json",
		async : true,
		data: {
			'hospCode': paramTabPage[tabId].hospCode,
			'depGroupCode': '',
			'depCode':'', 
			'wardCode':''
		},
		success : function(data) {
			dicDataTemp.hospInfo.wardData = data.data ;
		}
	})
	return dtd ;
}

// 该变量仅用于用于判断是否数据本科室,存储基本信息
var dicDataTemp = {"doctorInfo":null,"hospInfo":{}} ;

/**
 * 判断医师是否属于当前钻取科室
 * @param monitorType
 * @param tableData 加载的表格数据
 * @returns
 */
function isBelongToDep(monitorType,tableData) {
	var mtArray = ["protomedicus","clinic","resident","physician"] ;
	// 医师层 并打开了是否属于本科室功能开关
	if($.inArray(monitorType,mtArray)>-1 && (sysConfig.ISBELONGTODEP == 1)) {
		findDepDoctorIn(tableData) ;
	} 
}


/**
 * 根据配置获取科室相关信息
 */
function loadDepRelatedInfoByConfig () {
	// 需要数据并且尚未请求
	if(commonLayerConfig[0] == "1" && dicDataTemp.hospInfo.depGroupData == undefined) {
		getDepGroupByCode()
	}
	if(commonLayerConfig[1] == "1" && dicDataTemp.hospInfo.depData == undefined ) {
		findAllDepByHospCode()
	}
	if(commonLayerConfig[2] == "1" && dicDataTemp.hospInfo.wardData == undefined ) {
		getWardByCode();
	}
	if(dicDataTemp.doctorInfo == null ) {
		findAllDoctorInfo();
	}
}

/**
 * 查询医师所在科室
 * @param tableData 加载的表格数据
 * @returns
 */
function findDepDoctorIn(tableData) {
	var code = "" ;
	var param=drgUI.setAjaxData(tabId) ;
	if(param.parwardCode) {
		code = "parWardCode" ;
	} else if (param.pardepCode) {
		code = "parDepCode" ;
	} else if (param.pardepgroupCode) {
		code = "parDepGroupCode" ;
	}
	// 所有医师信息
	var doctorInfo = dicDataTemp.doctorInfo ;
	for(var i in tableData) {
		// 判断是否属于当前科室(科室组 病区),将判断结果和所在科室信息(描述)放入结果集
		var doccode = tableData[i].ccode ;
		if(doctorInfo[doccode]) {
			tableData[i].isBelongTo = isBelongTo(doctorInfo[doccode][code],doccode) ;
			// 如果不属于当前钻取科室则显示当前所在的科室名称
			if(tableData[i].isBelongTo == false) {
				tableData[i].currentDepName = mappingCodeToName(doctorInfo[doccode][code]) ;
			}
		}
	}
}

/**
 * 将编码映射为描述
 * code 科室 (病区，科室组)编码
 * @returns
 */
function mappingCodeToName(code) {
	var hospInfo = dicDataTemp.hospInfo ;
	// 映射字典值
	var dictionary = [];
	var param=drgUI.setAjaxData(tabId) ;
	var dicCode = "CODE" ;
	var dicName = "NAME" ;
	if(param.parwardCode) {
		dictionary = hospInfo.wardData;
	} else if (param.pardepCode) {
		dictionary = hospInfo.depData ;
		dicCode = "DEPCODE" ;
		dicName = "DEPNAME" ;
	} else if (param.pardepgroupCode) {
		dictionary = hospInfo.depGroupData ;
	}
	if(code) {
		code = code.split(",") ;
	} 
	var desc = "" ;
	// 多科室描述映射
	for(var o in code) {
		var dep = array_filter(dictionary,dicCode,[code[o]]);
		if(dep[0]) {
			desc += dep[0][dicName] + ",";
		} else { // 描述未找到,返回编码
			desc += code[o] + ",";
		}
	}
	return desc.substring(0,desc.length-1) ;
}

/**
 * 查询医师信息
 * @returns
 */
function findAllDoctorInfo() {
	$.post(contextPath + "/ClinicGroup/findAllClinicGroup.dhc", {}).done(function(data) {
		dicDataTemp.doctorInfo = data.data ;
		var doctorObj = {} ;
		var doctorInfo = dicDataTemp.doctorInfo ;
		for(var i in doctorInfo) {
			doctorObj[doctorInfo[i].groupCode] = doctorInfo[i] ;
		}
		dicDataTemp.doctorInfo = doctorObj ;
	})
}
/**
 * @ Discription:listMap合并,以code为主
 * @Autor ：liuhongjun
 * @Date  ：2018年4月8日下午3:48:27
 */
function mergeList(mainList, otherList,code,tail){
	if(!tail) {
		tail = "";
	}
	for(var i=0;i< mainList.length;i++){
		var mainMap=mainList[i];
		var mainCode=mainMap[code];
		for(var j=0;j<otherList.length;j++){
			var otherMap=otherList[j];
			var otherCode=otherMap[code];
			if(mainCode==otherCode){
				 for(var dataKey in otherMap)   {    
					 mainMap[dataKey+tail] = otherMap[dataKey]
				 } 
				 break;
			}
		}
	}
	return mainList;
}
/**
 * @ Discription:合并list，code：以谁为主，tail后code的后缀
 * @Autor ：liuhongjun
 * @Date  ：2018年4月8日下午5:00:19
 */
function mergeListcc(mainList, otherList,code,tail,quotaCode){
	if(!tail) tail = "cc";
	for(var i=0;i< mainList.length;i++){
		var mainMap=mainList[i];
		var mainCode=mainMap[code];
		for(var j=0;j<otherList.length;j++){
			var otherMap=otherList[j];
			var otherCode=otherMap[code];
			if(mainCode==otherCode){
				 for(var dataKey in otherMap)   {    
					 mainMap[dataKey] = otherMap[dataKey]
				 } 
				 mainMap[quotaCode]=mainMap["QuotaValue"];
				 var quotaCodecc=quotaCode+tail;
				 mainMap[quotaCodecc]=mainMap["QuotaValuecc"]==undefined?0:mainMap["QuotaValuecc"];
				 delete(mainMap["QuotaValue"]);
				 delete(mainMap["QuotaValuecc"]);
				 break;
			}
		}
	}
	return mainList;
}